<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('专家去世确认列表')"/>
</head>
<body class="gray-bg">
<div class="container-div" id="customlist">
    <div class="row">

        <!--登录信息-->
        <input name="userid" th:value="${session.userid}" type="hidden" id="userid">
        <input name="username" th:value="${session.username}" type="hidden" id="username">
        <input name="deptid" th:value="${session.deptid}" type="hidden" id="deptid">
        <input name="olddeptid" th:value="${session.olddeptid}" type="hidden" id="olddeptid">

        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>专家姓名：</label>
                            <input type="text" name="xingming"/>
                        </li>
                        <li>
                            <input type="text" th:value="${session.olddeptid}" name="jigoudaima" hidden/>
                        </li>
                        <li>
                            <label>工作单位：</label>
                            <input type="text" name="gongzuodanwei"/>
                        </li>
                        <li>
                            <label>身份证号：</label>
                            <input type="text" name="shenfenzhenghao"/>
                        </li>
                        <li>
                            <label style="width: 110px">死亡(注销)标记：</label>
                            <select name="siwangbiaoji" class="form-control" type="text">
                                <option value="">请选择</option>
                                <option value="注销">注销</option>
                                <option value="确定死亡">确定死亡</option>
                            </select>
                        </li>
                        <li>
                            <label>是否处理：</label>
                            <select name="shifouchuli" class="form-control" type="text">
                                <option value="">请选择</option>
                                <option value="0">未处理</option>
                                <option value="1">已处理</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>

    <!-- 编辑专家变动信息 -->
    <div th:replace="system/zhuanjiaqushiqueren/modal_edit::biandong_edit"></div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js" />
<script>
    var vm_customlist = new Vue({
        el: "#customlist",
        data:{
            biandong : {},//变动表
            zhuanjianame : '',
            deptid : $("#deptid").val(),		// 单位ID

            shifoubiandong : '',
        },
        created() {
            window.toAdd = this.toAdd
            window.toComfirm = this.toComfirm
            window.getDate = this.getDate
        },
        methods : {
            toAdd:function(id){
                var row = $("#bootstrap-table").bootstrapTable('getRowByUniqueId',id);
                $("#biandongModal").modal();
                this.biandong = {};
                this.biandong.zhuanjiaid = row.zhuanjiaid
                this.biandong.biandongleixing = 5
                this.zhuanjianame = row.xingming
                this.biandong.id = row.id
                this.biandong.biandongriqi = row.siwangriqi
                this.shifoubiandong = 0

            },
            getDate:function(){
                var _this = this;
                _this.biandong.biandongriqi=$("#biandongriqi").val();
            },
            toComfirm:function (id) {
                var _this = this
                var row = $("#bootstrap-table").bootstrapTable('getRowByUniqueId',id);
                _this.biandong.id = row.id
                $.modal.confirm("是否确认该专家无变动",function () {
                    $.post('/system/zhuanjiaqushiqueren/editQushi', {
                        id : _this.biandong.id,
                        shifouchuli : 1,
                    }, function (ppData) {
                        if (ppData != null) {
                            if (ppData.code == 0) {
                                layer.alert("提交成功");
                                $.table.refresh();
                            }
                            else {
                                layer.alert(ppData.msg);
                            }
                        }
                    })
                });
            },

            Submit:function(){
                var _this = this;

                if(_this.shifoubiandong=="0"){
                    _this.biandong.biandongleixing = "13"; //正常（健在）

                    var myDate = new Date;
                    var year = myDate.getFullYear(); //获取当前年
                    var mon = myDate.getMonth() + 1; //获取当前月
                    var date = myDate.getDate(); //获取当前日

                    _this.biandong.biandongriqi = year + "-" + mon + "-" + date;
                }

                var biandong_layer1 = layer.open({type: 3});
                $.post('/system/zhuanjiabiandongdetail/save', {
                    // biandongpiciid: _this.piciid,
                    deptid : _this.deptid,
                    zhuanjiaid : _this.biandong.zhuanjiaid,
                    biandongleixing : _this.biandong.biandongleixing,
                    biandongriqi : _this.biandong.biandongriqi,
                    shuoming : _this.biandong.shuoming,
                    rdm: Math.random()
                }, function (ppData) {
                    layer.close(biandong_layer1);
                    if (ppData != null) {
                        if (ppData.result == "1") {
                            if (confirm("确定要提交吗？")) {
                                var biandong_layer2 = layer.open({type:3});
                                $.post('/system/renwu/submit_custom', {
                                    id: ppData.resultContent,
                                    deptid: _this.deptid,
                                    rdm: Math.random()
                                }, function (ppData) {
                                    layer.close(biandong_layer2);
                                    if (ppData != null) {
                                        if (ppData.result == 1) {
                                            $.post('/system/zhuanjiaqushiqueren/editQushi', {
                                                id : _this.biandong.id,
                                                shifouchuli : 1,
                                                chulijieguo : _this.biandong.biandongleixing,
                                                shuoming : _this.biandong.shuoming,
                                            }, function (ppData) {
                                                if (ppData != null) {
                                                    if (ppData.code == 0) {
                                                        layer.alert("提交成功");
                                                        $("#biandongModal").modal("hide");
                                                        $.table.refresh();
                                                    }
                                                    else {
                                                        layer.alert(ppData.msg);
                                                    }
                                                }
                                            })
                                        } else {
                                            layer.alert(ppData.message);
                                        }
                                    }
                                }, "json");
                            }

                        } else {
                            layer.alert(ppData.message);
                        }
                    }
                }, "json");
            },
        }
    })
</script>
<script th:inline="javascript">
    var prefix = ctx + "system/zhuanjiaqushiqueren";
    $(function () {
        var options = {
            url: prefix + "/list",
            modalName: "专家去世确认",
            updateUrl: prefix + "/modaledit/{id}",
            uniqueId : 'id',
            columns: [{
                title: '序号',//标题  可不加
                formatter: function (value, row, index) {
                    return index + 1;
                }
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
/*                {
                    field: 'zhuanjiaid',
                    title: '专家ID'
                },*/
                {
                    field: 'xingming',
                    title: '专家姓名'
                },
                {
                    field: 'gongzuodanwei',
                    title: '工作单位'
                },
                {
                    field: 'shenfenzhenghao',
                    title: '身份证号'
                },
                {
                    field: 'siwangbiaoji',
                    title: '死亡(注销)标记'
                },
                {
                    field: 'siwangriqi',
                    title: '死亡日期'
                },
                {
                    field: 'beizhu',
                    title: '备注'
                },
                {
                    field: 'addtime',
                    title: '添加时间'
                },
                {
                    field: 'shifouchuli',
                    title: '是否处理',
                    formatter: function (value, row, index) {
                        return value==0?"未处理":"已处理";
                    },
                    cellStyle:function(value,row,index){
                        if (value !== null) {
                            if (value == 0) return {css:{"color":"red"}}
                            if (value == 1) return {css:{"color":"green"}}
                        }
                    }
                },
                {
                    field: 'chuliriqi',
                    title: '处理日期'
                },
                {
                    field: 'chulijieguo',
                    title: '处理结果'
                },
                {
                    field: 'shuoming',
                    title: '说明'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        var Flag = row.shifouchuli==0?"":"hidden"
                        actions.push('<a class="btn btn-warning btn-xs '+Flag+' "  href="javascript:void(0)"  onclick="toAdd(\'' + row.id + '\')">处理</i></a> ');
                        /*actions.push('<a class="btn btn-success btn-xs '+Flag+' "  href="javascript:void(0)"  onclick="toComfirm(\'' + row.id + '\')">核查无变动</i></a> ');*/
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>